A matching algorithm based on the negative selection for anomaly detection was presented in this paper. In the algorithm the effects of position between two temporal sequence to matching degree were considered. So it could distinguish accurately self and non-self, and reduced the size of detective set effectively. Using normal sequence calls, the initial detective set was created, and the detective set was extended by learning, according to the proportion of anomaly temporal sequence to judge whether this sequence was anomaly. Finally, the results of experiment was given.